package database;

import java.util.HashMap;
import java.util.Map;

import com.itany.mall.constant.UserRoleEnum;
import com.itany.mall.entity.Order;
import com.itany.mall.entity.OrderDetail;
import com.itany.mall.entity.Product;
import com.itany.mall.entity.ProductType;
import com.itany.mall.entity.User;

public class Database {

	public static Map<Long, User> users;
	public static long userId = 1;

	public static Map<Long, ProductType> productTypes;
	public static long productTypeId = 1;

	public static Map<Long, Product> products;
	public static long productId = 1;

	public static Map<Long, Order> orders;
	public static long orderId = 1;

	public static Map<Long, OrderDetail> orderDetails;
	public static long orderDetailId = 1;

	public static String USER_DIR = "./users";

	static {
		users = new HashMap<Long, User>();
		productTypes = new HashMap<Long, ProductType>();
		products = new HashMap<Long, Product>();
		orders = new HashMap<Long, Order>();
		orderDetails = new HashMap<Long, OrderDetail>();

		initUsers();
		initProducts();

		System.out.println(users);
		System.out.println(productTypes);
		System.out.println(products);
	}

	private static void initUsers() {
		//		User admin = new User(userId++, "admin", "123456", "13000000000", "admin@user.com", UserRoleEnum.ADMIN.getRoleCode());
		//		User alice = new User(userId++, "alice", "123456", "13000000001", "alice@user.com", UserRoleEnum.NORMAL.getRoleCode());
		//		User tom = new User(userId++, "tom", "123456", "13000000002", "tom@user.com", UserRoleEnum.NORMAL.getRoleCode());
		//		users.put(admin.getId(), admin);
		//		users.put(alice.getId(), alice);
		//		users.put(tom.getId(), tom);
	}

	private static void initProducts() {
		//		ProductType t1 = new ProductType(productTypeId++, "食品");
		//		ProductType t2 = new ProductType(productTypeId++, "饮料");
		//		ProductType t3 = new ProductType(productTypeId++, "日用品");
		//		productTypes.put(t1.getId(), t1);
		//		productTypes.put(t2.getId(), t2);
		//		productTypes.put(t3.getId(), t3);
		//
		//		Product p1 = new Product(productId++, "可喜可乐", 3.0, 0, t2);
		//		Product p2 = new Product(productId++, "乐土薯片", 5.0, 0, t1);
		//		Product p3 = new Product(productId++, "康帅傅包面", 4.0, 0, t1);
		//		Product p4 = new Product(productId++, "大动脉", 3.5, 0, t2);
		//		Product p5 = new Product(productId++, "手纸", 2.0, 0, t3);
		//		Product p6 = new Product(productId++, "肥皂", 3.5, 0, t3);
		//		products.put(p1.getId(), p1);
		//		products.put(p2.getId(), p2);
		//		products.put(p3.getId(), p3);
		//		products.put(p4.getId(), p4);
		//		products.put(p5.getId(), p5);
		//		products.put(p6.getId(), p6);
	}

}
